<%
var name = tb.pri.map(field=>under2Pascl(field.COLUMN_NAME)).join('And');
var tableName = tb.fields[0].TABLE_NAME;
var args = tb.pri.map(field=>{
	return `@Param("${under2Camel(field.COLUMN_NAME)}") ${field.JavaType} ${under2Camel(field.COLUMN_NAME)}`;
}).join(',');

var priWhere = tb.pri.map(field=>{
	return `${field.COLUMN_NAME} = #{${under2Camel(field.COLUMN_NAME)}}`;
}).join('and');

%>
	<!--
	* 根据主键查询
	-->
	
	
	 <select id="findByPrimaryKey" resultMap="BaseResultMap" >
       SELECT 
       <include refid="Base_Column_List" />
	   FROM <%-tableName%>
	   WHERE <%-priWhere%>
    </select>

	<!--
	* 根据主键删除
	-->
	<delete id="deleteBy<%-name%>">
       DELETE FROM
       		 <%-tableName%> 
       WHERE 
       		 <%-priWhere%>
    </delete>
	
<%
tb.uni.forEach(field=>{
%>
	
	<!--
	* 根据唯一索引查询
	-->

	<select id="findBy<%-under2Pascl(field.COLUMN_NAME)%>" resultMap="CasCadeResult"  >
       SELECT 
       <include refid="Base_Column_List" />
	   FROM <%-tableName%>
	   WHERE <%-field.COLUMN_NAME%>=#{<%-under2Camel(field.COLUMN_NAME)%>}
    </select>


	<!--
	* 根据唯一索引删除
	-->
	<delete id="deleteBy<%-under2Pascl(field.COLUMN_NAME)%>">
       DELETE FROM
       		 <%-tableName%> 
       WHERE 
       		 <%-field.COLUMN_NAME%>=#{<%-under2Camel(field.COLUMN_NAME)%>}
    </delete>
<%
});
%>

<% // 外健需要做查询
tb.fields.filter(field=>field.REFERENCED)
.forEach(field=>{
%>
	<!--
	根据外健查询,方便<%-field.REFERENCED.TABLE_NAME%>=><%-field.REFERENCED.COLUMN_NAME%>表做一对多
	-->

	<select id="findBy<%-under2Pascl(field.COLUMN_NAME)%>" resultMap="BaseResultMap" >
       SELECT 
       <include refid="Base_Column_List" />
	   FROM <%-tableName%>
	   WHERE <%-field.COLUMN_NAME%>=#{<%-under2Camel(field.COLUMN_NAME)%>}
    </select>

<%
});
%>